package netty.websocket;

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;

/**
 * @author shkstart
 * @create 2019-11-15 19:47
 */
public class WebSocketServer {

    public static void main(String[]args) throws InterruptedException {

        EventLoopGroup mainLoopGroup=new NioEventLoopGroup();
        EventLoopGroup subLoopGroup=new NioEventLoopGroup();

        try {
            ServerBootstrap serverBootstrap=new ServerBootstrap();
            serverBootstrap.group(mainLoopGroup,subLoopGroup)
                    .channel(NioServerSocketChannel.class)
                    .childHandler(new WsChannelInitializer());

            ChannelFuture channelFuture=serverBootstrap.bind(8088).sync();

            channelFuture.channel().closeFuture().sync();
        }finally {
            mainLoopGroup.shutdownGracefully();
            subLoopGroup.shutdownGracefully();
        }



    }
}
